import urllib.request

headers = {
    'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36'
}
url = "https://movie.douban.com"
#如果需要传递headers，要通过Request对象来传递信息
req = urllib.request.Request(url,headers=headers)
#直接打开req对象即可
resp = urllib.request.urlopen(req)
html = resp.read().decode("utf-8")
#此时爬取的是html的静态数据
print(html)